package client

import (
	"context"
	"fmt"
	"google.golang.org/grpc"
	pt "test_chat/protobuf"
)

const (
	post = "127.0.0.1:18887"
)

func TestGrpcClient() {
	conn, err := grpc.Dial(post, grpc.WithInsecure())
	if err != nil {
		panic(err)
	}

	defer conn.Close()
	client := pt.NewHellowServerClient(conn)
	// say hellow

	hellow, err := client.SayHellow(context.Background(), &pt.HellowRequest{
		Name: "TestGrpcClient",
	})
	if err != nil {
		panic(err)
	}
	fmt.Println("Client reply:" + hellow.GetMessage())

	msg, err := client.GetHellowMsg(context.Background(), &pt.HellowRequest{
		Name: "TestGrpcClient call hellow msg",
	})
	if err != nil {
		panic(err)
	}
	fmt.Println("Client call get hellow msg:" + msg.Msg)
}
